Skip to content

Win: Add no console by default and attach later - #964

Open
yuxiaomao wants to merge 3 commits into
HaxeFoundation:masterfrom
yuxiaomao:dev-create-console
Open

Win: Add no console by default and attach later#964
yuxiaomao wants to merge 3 commits into
HaxeFoundation:masterfrom
yuxiaomao:dev-create-console

Conversation

@yuxiaomao

@yuxiaomao yuxiaomao commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

It seems that sometimes for a game release, we don't want the cmd window pop-up. This PR:

  • Added wWinMain in main.c so one can compile with subsystem:windows
  • Added ui_create_console, ui_attach_console to enable the console when we need it (API in haxe)
  • Activated for the configuration ReleaseDX12Agility

The downside (?) is that the console window will look like a normal window instead of a cmd window.

Haxe side API:

	#if (hl_ver >= version("1.16.0"))
	@:hlNative("?ui", "ui_create_console")
	public static function createConsole():Bool {
		return false;
	}

	@:hlNative("?ui", "ui_attach_console")
	public static function attachConsole(pid:Int):Bool {
		return false;
	}
	#end

For a better experience with debugger I think the expected usage is :

if( !hl.Api.hasDebugger() ) {
	hl.UI.createConsole();
}

@yuxiaomao

Copy link
Copy Markdown
Collaborator Author

Another pb when the debugger is attached (and as we don't do createConsole to keep the trace inside the debugger) is that now every Sys.command will spawn its own console, which is not ideal

Comment thread src/main.c Outdated
return 0;
}

#ifdef HL_WIN

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to have && !defined(_CONSOLE), so people can still compile it for the console subsystem. This would match hlc_main.c:

#if (defined(HL_WIN_DESKTOP) && !defined(_CONSOLE)) || defined(HL_XBS)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can keep the same (but it seems still compile when choosing console subsystem).
HL_XBS can use the same too because I copied the function from HL_XBS, so I put the same condition here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants